package com.situ.mymall.controller;

import com.situ.mymall.pojo.entity.Shipping;
import com.situ.mymall.pojo.query.ShippingQuery;
import com.situ.mymall.service.IShippingService;
import com.situ.mymall.util.PageResult;
import com.situ.mymall.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shipping")
public class ShippingController {

    @Autowired
    private IShippingService shippingService;

    //展示商品--前端占有了，需要重新写
    @RequestMapping("/list")
    public PageResult list(ShippingQuery shippingQuery){
        return shippingService.list(shippingQuery);
    }

    //添加商品
    @RequestMapping("/add")
    public Result add(Shipping shipping){
        shippingService.add(shipping);
        return Result.ok("添加成功");
    }

    //查询id
    @RequestMapping("/selectById")
    public Result selectById(Integer id){
        Shipping shipping = shippingService.selectById(id);
        return Result.ok(shipping);
    }

    //更新--xml没写
    @RequestMapping("/update")
    public Result update(Shipping shipping){
        shippingService.update(shipping);
        return Result.ok("更新成功");
    }

    //删除单个数据
    @RequestMapping("/deleteById")
    public Result deleteById(Integer id){
        shippingService.deleteById(id);
        return Result.ok("删除成功");
    }

    //批量删除
    @RequestMapping("/deleteAll")
    public Result deleteAll(Integer[] ids){
        shippingService.deleteAll(ids);
        return Result.ok("删除成功");
    }

}
